import com.atguigu.gmall.realtime.bean.KeywordBean;

import java.lang.reflect.Field;

/**
 * @Author lzc
 * @Date 2023/2/17 14:56
 */
public class ReflectDemo {
    public static void main(String[] args) throws Exception {
        KeywordBean bean = new KeywordBean();
        bean.setStt("abc");
        
        Class<KeywordBean> tClass = KeywordBean.class;
    
//        Field[] fields = tClass.getFields();
        Field[] fields = tClass.getDeclaredFields();
    
        /*String msg = "";
        for (Field field : fields) {
            msg += field.getName() + ",";
        }
        System.out.println(msg);*/
       /* String msg = Arrays.stream(fields)
            .map(f -> f.getName())
            .collect(Collectors.joining(","));
        System.out.println(msg);*/
    
        Field stt = tClass.getDeclaredField("stt");
        stt.setAccessible(true);
        Object v = stt.get(bean);
        System.out.println(v);
    
        stt.set(bean, "ffff");
        System.out.println(bean);
    
    
    }
}
